#include "DoOpString.h"
#include "DevilSemantic.h"

void DoOpString::ds_string::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1 = state.getOpStack().pop();
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	
	obj2 = newString("");
	state.getOpStack().push(obj2);
}

void DoOpString::ds_length::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1 = state.getOpStack().pop();
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	
	DoString * str = toString(obj1);
	if (str->getType() == DoString::ePlain) {
		int len = strlen(obj1->getText());
		state.getOpStack().push(newNumber(len));
	} else {
		CXXTHROW
	}
}

bool DoOpString::ds_length::match(DevilSemantic &state) const 
{
	if (state.getOpStack().size() < 1)
		return false;
	CRefPtr< _DoObject > obj1 = state.getOpStack().top(0);
	if (obj1->type() == eString)
		return true;
	return false;
}

void DoOpString::ds_get::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

bool DoOpString::ds_get::match(DevilSemantic &state) const 
{
	if (state.getOpStack().size() < 2)
		return false;
	CRefPtr< _DoObject > obj1 = state.getOpStack().top(1);
	if (obj1->type() == eString)
		return true;
	return false;
}

void DoOpString::ds_put::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

bool DoOpString::ds_put::match(DevilSemantic &state) const 
{
	if (state.getOpStack().size() < 3)
		return false;
	CRefPtr< _DoObject > obj1 = state.getOpStack().top(2);
	if (obj1->type() == eString)
		return true;
	return false;
}

void DoOpString::ds_getinterval::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

void DoOpString::ds_putinterval::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

void DoOpString::ds_copy::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

bool DoOpString::ds_copy::match(DevilSemantic &state) const 
{
	if (state.getOpStack().size() < 1)
		return false;
	CRefPtr< _DoObject > obj1 = state.getOpStack().top(0);
	if (obj1->type() == eString)
		return true;
	return false;
}

void DoOpString::ds_forall::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

bool DoOpString::ds_forall::match(DevilSemantic &state) const 
{
	if (state.getOpStack().size() < 2)
		return false;
	CRefPtr< _DoObject > obj1 = state.getOpStack().top(1);
	if (obj1->type() == eString)
		return true;
	return false;
}

void DoOpString::ds_anchorsearch::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

void DoOpString::ds_search::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

void DoOpString::ds_token::execute(DevilSemantic &state)
{
	CRefPtr< _DoObject > obj1;
	CRefPtr< _DoObject > obj2;
	CRefPtr< _DoObject > obj3;
	CRefPtr< _DoObject > obj4;
	CRefPtr< _DoObject > obj5;
	CXXTHROW
}

